package cn.fl.system.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;

import cmm.user.facade.system.api.IPriorityApiService;
import cmm.user.facade.system.dto.SysUsrDatAuthRDTO;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.system.service.ISysUsrDatAuthRService;
import cn.fl.system.transform.SysUsrDatAuthRVOTransform;
import cn.fl.system.vo.SysUsrDatAuthRVO;

@Service
public class SysUsrDatAuthRServiceImpl implements ISysUsrDatAuthRService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(SysUsrDatAuthRServiceImpl.class);
	
	/**
	 *  权限暴露服务
	 */
	@Autowired
	private IPriorityApiService priorityApiService;

	@Override
	public SysUsrDatAuthRVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id))return null;
		SysUsrDatAuthRDTO dto = null;//this.自定义ApiService.selectById(id);
		return SysUsrDatAuthRVOTransform.toVO(dto);
	}

	@Override
	public boolean addSysUsrDatAuthR(List<SysUsrDatAuthRVO> list)
			throws BaseException {
		if(CollectionUtils.isEmpty(list)){
			BaseLogUtils.info(logger, "addSysUsrDatAuthR", "新增数据权限关联关系失败,对象为空.DATA:"+JSONObject.toJSONString(list), CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.priorityApiService.addSysUsrDatAuthR(SysUsrDatAuthRVOTransform.toDTOList(list));
	}

	@Override
	public boolean removeSysUsrDatAuthR(Long orgId, List<Long> usrIds)
			throws BaseException {
		if(StringUtils.isEmpty(orgId)||CollectionUtils.isEmpty(usrIds)){
			BaseLogUtils.info(logger, "removeSysUsrDatAuthR", "删除数据权限关联关系失败,组织架构ID或用户IDS为空.orgId:"+orgId+",usrIds:"+JSONObject.toJSONString(usrIds), CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.priorityApiService.removeSysUsrDatAuthR(orgId, usrIds);
	}

	@Override
	public boolean modifySysUsrDatAuthRVO(List<SysUsrDatAuthRVO> voList)
			throws BaseException {
		if(CollectionUtils.isEmpty(voList)){
			BaseLogUtils.info(logger, "modifySysUsrDatAuthRVO", "修改数据权限关联关系失败,对象为空.DATA:"+JSONObject.toJSONString(voList), CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.priorityApiService.modifySysUsrDatAuthR(SysUsrDatAuthRVOTransform.toDTOList(voList));
	}

	/*@Override
	public Long add(SysUsrDatAuthRVO entity) throws BaseException{
		if(null == entity)return null;
		return this.sysUsrDatAuthRApiService.add(SysUsrDatAuthRVOTransform.toDTO(entity));
	}*/

	/*@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id))return false;
		return this.sysUsrDatAuthRApiService.removeById(id);
	}*/

	/*@Override
	public boolean modify(SysUsrDatAuthRVO entity) throws BaseException{
		if(null == entity)return false;
		return this.sysUsrDatAuthRApiService.modify(SysUsrDatAuthRVOTransform.toDTO(entity));
	}*/

	/*@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		return this.sysUsrDatAuthRApiService.searchListPage(page);
	}*/
}
